package com.jwl.idc.customview;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jwl.idc.R;

/**
 * Created by liangfan on 2016/1/6.
 * descript : 自定义的tiltebar
 */
public class TitleBar extends LinearLayout {
    private TextView backTv, contentTv, moreTv;

    public TitleBar(Context context) {
        this(context, null);
    }

    public TitleBar(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }



    public void initView(Context context) {
        LayoutInflater mInflater = LayoutInflater.from(context);
        mInflater.inflate(R.layout.titlebar, this, true);    //注意此次最后一个参数为 true
        backTv = (TextView) findViewById(R.id.titleBackTv);
        contentTv = (TextView) findViewById(R.id.titleContentTv);
        moreTv = (TextView) findViewById(R.id.titleMoreTv);
    }
    public void setText(String backStr,String contentStr,String moreStr){
        backTv.setText(backStr);
        contentTv.setText(contentStr);
        moreTv.setText(moreStr);
    }

    public void showAllVisible() {
        backTv.setVisibility(View.VISIBLE);
        contentTv.setVisibility(View.VISIBLE);
        moreTv.setVisibility(View.VISIBLE);

    }

    public void showLeftImageVisible(int res){
        backTv.setBackgroundResource(res);
    }

    public void showLeftVisible() {
        backTv.setVisibility(View.VISIBLE);
        contentTv.setVisibility(View.VISIBLE);
        moreTv.setVisibility(View.GONE);
    }

    public void setClickListener(OnClickListener click) {
        backTv.setOnClickListener(click);
        moreTv.setOnClickListener(click);
    }
}
